package com.xiaoliang.servlet;

import com.xiaoliang.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author XIAOLIANG
 * @ClassName DeleteChecked.java
 * @Description TODO
 * @createTime 2021年02月26日 14:47:00
 */
//@WebServlet("/product/deleteChecked")
public class DeleteChecked extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		String[] ids = req.getParameterValues("id");

		ProductServiceImpl productService = new ProductServiceImpl();

		if (ids!=null){

			for (String id : ids) {

				productService.deleteProduct(Integer.parseInt(id));
				System.out.println("删除商品的ID"+id);
			}

		}

		resp.sendRedirect(req.getContextPath()+"/product/productList");

	}
}
